<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<script>




//【示例1】下面代码演示了如何使用indexOf 方法。
var ar = ["ab", "cd", "ef", "ab", "cd"];
document.write(ar.indexOf("cd") + "<br/>");		//1
document.write(ar.indexOf("cd", 2) + "<br/>");		//4
document.write (ar.indexOf("gh")+ "<br/>");		//-1
document.write (ar.indexOf("ab", -2) + "<br/>");	//3


//【示例2】下面代码演示了如何使用indexOf 方法。
var ar = ["ab", "cd", "ef", "ab", "cd"];
document.write(ar.lastIndexOf("cd") + "<br/>");	//4
document.write(ar.lastIndexOf("cd", 2) + "<br/>");//1
document.write(ar.lastIndexOf("gh")+ "<br/>");		//-1
document.write(ar.lastIndexOf("ab", -3) + "<br/>");//0


</script>
</head>
<body>




</body>
</html>
